﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="${pageContext.request.contextPath}/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<%@ include file="base.jsp" %>
<script src="${pageContext.request.contextPath}/js/jquery.min.js" type="text/javascript"></script>   
<script src="${pageContext.request.contextPath}/js/base.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerGrid.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerForm.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDateEditor.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerToolBar.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerComboBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerCheckBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerRadio.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerSpinner.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerTextBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/inject.js" type="text/javascript"></script> 
<script src="${pageContext.request.contextPath}/js/ligerPopupEdit.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDialog.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerTip.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.metadata.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/messages_cn.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common/ligerUiCommon.js" type="text/javascript"></script>  
<script src="${pageContext.request.contextPath}/js/common/ajax.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common/dateFormateUtil.js" type="text/javascript"></script>
<script type="text/javascript"> 
	var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
	var isSaveAndCreate = false;
	//添加校验
	$(function() {
		addValidate(submitData);
		$("form").ligerForm();
	});
	
		//初始化
		$(function() {
			var dialogData = dialog.get('data');//获取data参数
			$("#ddId").val(dialogData.ddId);
			$("#ddh").val(dialogData.ddh);
			if(dialogData.ddxxId) {
				$("#ddxxId").val(dialogData.ddxxId);
				$("#xh").val(dialogData.xh);
				$("#sl").val(dialogData.sl);
				$("#dj").val(dialogData.dj);
				$set("xslx", dialogData.xslx);
			} 
		});

	//提交商品信息
	function submitData() {
		if($("#error_ddh").html() != null && $("#error_ddh").html().length != 0) {
			return;
		}
		var dd = {};
		dd.id = $("#ddxxId").val();
		dd.ddid = $("#ddId").val();
		dd.ddh = $("#ddh").val();
		dd.xh = $("#xh").val();
		dd.sl = $("#sl").val();
		dd.dj = $("#dj").val();
		dd.xslx = $("#xslx").val();
		dd.userid = "${user.id}";
		var url = "${pageContext.request.contextPath}/DdglAction?control=saveDdxxxx";
		sendAjaxRequest(url, JSON.stringify(dd), false, function(msg) {
			if(msg.data == "保存成功") {
				window.parent.manager.reload();
				if(!isSaveAndCreate) {
					dialog.close();					
				} 
			} else {
				$.ligerDialog.error(msg.data);
			}
		});
	}
	
	function save() {
		isSaveAndCreate = false;
		$('#ddxxglForm').submit();
	}
	
	function saveAndCreate() {
		isSaveAndCreate = true;
		$('#ddxxglForm').submit();
		$("#xh").val("");
		$("#sl").val(1);
		$("#dj").val("");
		$("#ddxxId").val("");
	}
	
	//刷新页面
	function clearInput() {
		location.reload();
	}
</script>
<!--[if IE 6]>
   <script src="js/DD_belatedPNG.js"></script>
   <script>DD_belatedPNG.fix('.xxjbb_5 img');</script>
<![endif]-->
<title></title>
</head>
<style type="text/css">
body{background:#ffffff}
html{_overflow-y:scroll;}
</style>
<body>
<div class="xxjbb_position">
<table width="100%" align="left" cellpadding="0" cellspacing="0">
  <tr>
    <td class="xxjbb_1 xxjbb_3">
     <ul>
       <li><a href="#" onclick="save()">保存</a></li>
       <li><a href="#" onclick="saveAndCreate()">保存并增加</a></li>
     </ul>
   </td>
  </tr>
</table>
</div>
<div class="xxjbb_4">
 <form id="ddxxglForm" name="ddxxglForm" method="post" >
  <table width="100%" align="left" cellpadding="0" cellspacing="0" class="bjkcxx">
  <input type="hidden" id="ddxxId" />
  <input type="hidden" id="ddId" />
  <input type="hidden" id="ddh" />
      <tr>
        <td class="xxjbb_mc" width="20%"><b>名称</b></td>
        <td class="xxjbb_mccc" width="80%"><b>值</b></td>
      </tr>
      <tr>
        <td class="xxjbb_b">型号*</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input id="xh" type="text" validate="{required:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">数量</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input  id="sl" name="sl" type="text" value="1" validate="{required:true,digits:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">单价*</td>
        <td class="xxjbb_zzz">
          <table>
            <tr>
              <td><input  id="dj" name="dj" type="text" validate="{required:true,digits:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">销售类型（批发/零售）</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td>
              	<select id="xslx"> 
              		<option value="批发" selected="selected">批发</option>
              		<option value="零售">零售</option>
              	</select>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </form>
</div>
</body>
</html>
